<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
if (!defined('BASEPATH'))
    exit('No direct script access allowed');

class Berbah extends CI_Model {

    function __construct() {
        parent::__construct();
    }

    function get_sys() {
        $get = $this->db->get('sys');
        if ($get->num_rows > 0) {
            return $get->result();
        }
    }

    function login($log) {
        $this->db->where('username', $log['username']);
        $this->db->where('password', $log['password']);
        $data = $this->db->get('user');
        if ($data->num_rows == 1) {
            return $data->row();
        } else {
            return FALSE;
        }
    }
    
    function get_kk(){
        $get = $this->db->get('vget_kk');
        if($get->num_rows > 0){
            return $get->result();
        }
    }
    
    function get_pndk() {
        $get = $this->db->get('vget_pnddk');
        if ($get->num_rows > 0) {
            return $get->result();
        }
    }

    function get_pndk_nik($nik) {
        $this->db->where('nik', $nik);
        $get = $this->db->get('vget_pnddk');
        if ($get->num_rows > 0) {
            return $get->result();
        }
    }
    
    function get_pndk_kk($kk) {
        $this->db->where('kk_id', $kk);
        $get = $this->db->get('vget_pnddk');
        if ($get->num_rows > 0) {
            return $get->result();
        }
    }
    
    // Fungsi delete
    function del_nik($nik){
        $this->db->where('nik',$nik);
        $this->db->delete('penduduk');
    }

}

?>
